﻿#region Header
// ------------------------ Licence / Copyright ------------------------
// 
// Simple Service Administration Tool for WinNT based systems.
// Copyright © 2010 - Silvan Gehrig
// 
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
// 
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
// 
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
// 
// Author:
//  Silvan Gehrig
//
// ---------------------------------------------------------------------
#endregion

#region Usings

using System;
using System.Text;
using System.Collections;

#endregion

namespace SSATool.Common.Util.ExtensionMethods
{
    /// <summary>
    /// Contains the global utilities for the IDisposable class.
    /// </summary>
    public static class DisposableUtil
    {
        #region Methods

        //--------------------------------------------------------------------
        // Methods
        //--------------------------------------------------------------------

        /// <summary>
        /// Tries to dispose the specified instance and ignores exceptions
        /// of type T.
        /// </summary>
        /// <param name="input">Input pointer from extension method.</param>
        public static void TryDispose<T>(this IDisposable input)
            where T : Exception
        {
            try
            {
                input.Dispose();
            }
            catch (T)
            {
                // ignore this exception, it is expected to be thrown
            }
        }

        #endregion
    }
}
